﻿using MediatR;

using Microsoft.AspNetCore.Mvc;

using S.Y.Passport.ErroeCode;
using S.Y.Passport.Read.API.Applications.Commands;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;



namespace S.Y.Passport.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public ManagementController(IMediator mediator) 
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public Task<SyResult<object>> GoodsAdd(GoodsAddCommand command)
        {
            try
            {
                return mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpDelete]
        public Task<SyResult<object>> GoodsDel(GoodsDelCommand command)
        {
            try
            {
                return mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPut]
        public Task<SyResult<object>> GoodsUpdate(GoodsUpdateCommand command)
        {
            try
            {
                return mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
